home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
197_01
/
boxmac.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
1980-01-01
|
12KB
|
590 lines
; BOXMAC.CMD: Standard Micro Startup Box drawing macroes
; for MicroEMACS 3.9
; (C)opyright 1987 by Suresh Konda and Daniel M Lawrence
; Last Update: 07/12/87
write-message "[Loading Box Macroes]"
;this macro inserts enough characters at the end of line to lineup with point
store-procedure mvtopcol
;set $debug TRUE
end-of-line
set %temp &sub %pcol $curcol
!if &less $curcol %pcol
;; current position to left of point -- blank fill to point
; !if &gre %temp 0
%temp insert-string " "
; !endif
!else
!if &less %temp 0
set %temp &neg %temp
%temp backward-character
!else
%temp forward-character
!endif
!endif
!endm
;this macro inserts enough characters at the end of line to lineup with mark
store-procedure mvtomcol
;set $debug TRUE
end-of-line
!if &less %mcol $curcol
;; current position to right of mark -- move to mark
; insert-string &cat &cat %mcol " " $curcol
beginning-of-line
%mcol forward-character
!else
;; current position is to left of mark -- blank fill
set %temp &sub %mcol $curcol
!if &gre %temp 0
%temp insert-string " "
!endif
!endif
!endm
store-procedure inschar
!if &equal %char 205
insert-string &chr %c1
!else
!if &equal %char 196
insert-string &chr %c2
!else
insert-string &chr %c3
!endif
!endif
!endm
store-procedure box2
;remember point
set %pcol &add $curcol 1
set %pline $curline
exchange-point-and-mark
;remember mark
; set %mcol &add $curcol 1
set %mcol $curcol
set %mline $curline
;draw top horizontal line
insert-string "╔"
set %width &sub &sub %pcol %mcol 1
%width insert-string "═"
insert-string "╗"
newline-and-indent
; insert-string " "
;draw bottom horizontal line
%pline goto-line
; we are now one line above old last line because of insertion of top line
next-line
end-of-line
newline
run mvtomcol
insert-string "╚"
%width insert-string "═"
insert-string "╝"
; bump pline
set %pline &add %pline 1
;draw verticals
%mline goto-line
;we are at top -- draw verticals
*lp1
next-line
run mvtomcol
insert-string "║"
run mvtopcol
insert-string "║"
!if &less $curline %pline
!goto lp1
!endif
;return to point
%pline goto-line
next-line
beginning-of-line
%width forward-character
2 forward-character
!endm
store-procedure setpoints
;; procedure will set pcol, pline, mcol and mline
set %pcol $curcol
set %pline $curline
exchange-point-and-mark
set %mcol $curcol
set %mline $curline
exchange-point-and-mark
!endm
;; user procedure to draw a double line from mark to point making spaces for
;; the characters.
store-procedure line2
run setpoints
!if &equal %pcol %mcol
run vert2
!else
!if &equal %pline %mline
run hor2
!else
write-message "Illegal point and mark for lines"
!endif
!endif
!endm
;; user procedure to draw line from mark to point making spaces for
;; the characters.
store-procedure line1
run setpoints
!if &equal %pcol %mcol
run vert1
!else
!if &equal %pline %mline
run hor1
!else
write-message "Illegal point and mark for lines"
!endif
!endif
!endm
store-procedure hor2
;; procedure to draw a double line from beginning of line to point
;; assume that the current line is to be double underlined. pcol,mcol,pline,
;; mline already set by calling macro
!if &equal %mcol %pcol
write-message "in hor equal cols"
!return
!endif
!if &less %pcol %mcol
; then point was to left of mark. exchange and reset variables
exchange-point-and-mark
run setpoints
!endif
end-of-line
newline
;; move to under mark
!if &greater %mcol 1
%mcol insert-string " "
!endif
;; see if first char is a vertical line
previous-line
set %char $curchar
next-line
!if &equ %char 186
insert-string "╠"
!else
!if &equ %char 179
insert-string "╞"
!else
insert-string "═"
!endif
!endif
; now for all chars but the last character i.e., char at point
*lp1
previous-line
set %char $curchar
next-line
!if &equ %char 186
insert-string "╬"
!else
!if &equ %char 179
insert-string "╪"
!else
insert-string "═"
!endif
!endif
!if &less $curcol %pcol
!goto lp1
!endif
;; see if last char is a vertical line
previous-line
set %char $curchar
next-line
!if &equ %char 186
insert-string "╣"
!else
!if &equ %char 179
insert-string "╡"
!else
insert-string "═"
!endif
!endif
!endm
store-procedure hor1
;; procedure to draw a single line from beginning of line to point
!if &equal %mcol %pcol
write-message "in hor equal cols"
!return
!endif
!if &less %pcol %mcol
; then point was to left of mark. exchange and reset variables
exchange-point-and-mark
run setpoints
!endif
end-of-line
newline
;; move to under mark
!if &greater %mcol 1
%mcol insert-string " "
!endif
;; see if first char is a vertical line
previous-line
set %char $curchar
next-line
!if &equ %char 186
insert-string "╟"
!else
!if &equ %char 179
insert-string "├"
!else
insert-string "─"
!endif
!endif
; now for all chars but the last character i.e., char at point
*lp1
previous-line
set %char $curchar
next-line
!if &equ %char 186
insert-string "╫"
!else
!if &equ %char 179
insert-string "┼"
!else
insert-string "─"
!endif
!endif
!if &less $curcol %pcol
!goto lp1
!endif
;; see if last char is a vertical line
previous-line
set %char $curchar
next-line
!if &equ %char 186
insert-string "╢"
!else
!if &equ %char 179
insert-string "┤"
!else
insert-string "─"
!endif
!endif
!endm
store-procedure vert2
;; procedure to draw a line from mark to point. mark should be above point
;; this will insert a column of double lines
!if &equal %mline %pline
!return
!endif
!if &less %pline %mline
; then point was above mark. exchange and reset variables
exchange-point-and-mark
run setpoints
!endif
;top line
%mline goto-line
beginning-of-line
run mvtopcol
backward-character
set %char $curchar
forward-character
!if &equal %char 205
insert-string "╦"
!else
!if &equal %char 196
insert-string "╥"
!else
insert-string "║"
!endif
!endif
;all but pline
*lp1
next-line
beginning-of-line
run mvtopcol
backward-character
set %char $curchar
forward-character
!if &equal %char 205
insert-string "╬"
!else
!if &equal %char 196
insert-string "╫"
!else
insert-string "║"
!endif
!endif
!if &less $curline &sub %pline 1
!goto lp1
!endif
; bottom line
next-line
beginning-of-line
run mvtopcol
backward-character
set %char $curchar
forward-character
!if &equal %char 205
insert-string "╩"
!else
!if &equal %char 196
insert-string "╨"
!else
insert-string "║"
!endif
!endif
!if &less $curcol &sub %pcol 1
!goto lp1
!endif
!endm
store-procedure vert1
;; procedure to draw a line from mark to point. mark should be above point
;; this will insert a column of double lines
!if &equal %mline %pline
!return
!endif
!if &less %pline %mline
; then point was above mark. exchange and reset variables
exchange-point-and-mark
run setpoints
!endif
;top line
%mline goto-line
beginning-of-line
run mvtopcol
backward-character
set %char $curchar
forward-character
!if &equal %char 205
insert-string "╤"
!else
!if &equal %char 196
insert-string "┬"
!else
insert-string "│"
!endif
!endif
;all but pline
*lp1
next-line
beginning-of-line
run mvtopcol
backward-character
set %char $curchar
forward-character
!if &equal %char 205
insert-string "╪"
!else
!if &equal %char 196
insert-string "┼"
!else
insert-string "│"
!endif
!endif
!if &less $curline &sub %pline 1
!goto lp1
!endif
; bottom line
next-line
beginning-of-line
run mvtopcol
backward-character
set %char $curchar
forward-character
!if &equal %char 205
insert-string "╧"
!else
!if &equal %char 196
insert-string "┴"
!else
insert-string "│"
!endif
!endif
!if &less $curcol &sub %pcol 1
!goto lp1
!endif
!endm
;; user procedure to insert blanks from mark to point